import instance from '@/http/index.js'

// 获取用户信息
export const getUserInfo = (id) => {
  return instance.post('/user/getUserInfo',{id})
}

//修改密码
export const changePassword = (id,oldPassword,newPassword) => {
  return instance.post('/user/changePassword',{id,oldPassword,newPassword})
}
//修改姓名
export const changeName = (id,name) => {
  return instance.post('/user/changeName',{id,name})
}
//修改邮箱
export const changeEmail = (id,email) => {
  return instance.post('/user/changeEmail',{id,email})
}
//修改性别
export const changeSex = (id,sex) => {
  return instance.post('/user/changeSex',{id,sex})
}
//头像绑定账号
export const bindAccount = (account,onlyId,url) => {
  return instance.post('/user/avatarBindAccount',{account,onlyId,url})
}

// --------------------------------------------
// 用户管理

// 创建管理员
export const createAdmin = (data) => {
  const {account,password,sex,name,email,department,identity} = data
  return instance.post('/user/createAdmin',{account,password,sex,name,email,department,identity})
}
// 获取管理员列表
export const getAdmin = (identity) => {
  return instance.post('/user/getAdmin',{identity})
}

// 编辑管理员信息
export const editAdmin = (data) => {
  const {id, name, sex, email, department,identity} = data
  return instance.post('/user/editAdmin',{id, name, sex, email, department,identity})
}

//修改管理员身份
export const changeIdentity = (id,identity) => {
  return instance.post('/user/changeIdentity',{id,identity})
}

//通过账号和身份搜索用户
export const searchUser = (account,identity) => {
  return instance.post('/user/searchUser',{account,identity})
}

//解冻或者冻结用户
export const controlStatus = (id,status) => {
  return instance.post('/user/controlStatus',{id,status})
}

//获取冻结用户列表
export const getFrozenUser = () => {
  return instance.post('/user/getFrozenUser')
}

//删除用户
export const deleteUser = (id,account) => {
  return instance.post('/user/deleteUser',{id,account})
}

//通过部门获取用户
export const getUserByDepartment = (department) => {
  return instance.post('/user/getUserByDepartment',{department})
}

//获取对应身份用户的长度
export const getUserLength = (identity) => {
  return instance.post('/user/getUserLength',{identity})
}

//监听分页查询用户信息
export const getUserListByPage = (identity,page) => {
  return instance.post('/user/getUserListByPage',{identity,page})
}